package main

import (
	"flag"
	"github.com/cheng1005/XxCh-Common/common/inits"
	"github.com/gin-gonic/gin"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log"
	"zg6/zk1/doctor-management/api/router"
	"zg6/zk1/doctor-management/common/global"
	"zg6/zk1/doctor-management/common/proto/doctors"
)

func main() {
	inits.InitViper()
	inits.InitNaCos()
	DoctorGrpc()
	r := gin.Default()
	router.LoadRouter(r)
	r.Run()
}

func DoctorGrpc() {
	flag.Parse()
	// Set up a connection to the server.
	conn, err := grpc.NewClient("localhost:8899", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	global.DoctorGrpc = doctors.NewDoctorSrvClient(conn)
}
